home *** CD-ROM | disk | FTP | other *** search
/ Programming Sound Cards / Programming Sound Cards.iso / sound_25 / example1.c < prev    next >
C/C++ Source or Header  |  1995-01-01  |  3KB  |  105 lines

  1. /************************************************************************/
  2. /*                                                                      */
  3. /*                 Digitized Voice Programmer's Toolkit                 */
  4. /*                 ------------------------------------                 */
  5. /*                            version 3.0                               */
  6. /*                                                                      */
  7. /*              Copyright (c) 1988-1993, Farpoint Software              */
  8. /*                                                                      */
  9. /*                                                                      */
  10. /*  Example of how to use FSSPEAK.EXE as a transient (non-TSR) program  */
  11. /*                                                                      */
  12. /************************************************************************/
  13.  
  14. #include <stdlib.h>
  15. #include <fcntl.h>
  16. #include <io.h>
  17. #include <sys\types.h>
  18. #include <sys\stat.h>
  19. #include <stdio.h>
  20. #include <stddef.h>
  21. #include <malloc.h>
  22. #include <process.h>
  23. #include <errno.h>
  24. #include <string.h>
  25.  
  26. /*-------------------------------------------------------------------*/
  27.  
  28. /* name of the data file to be played */
  29.  
  30. char datafilename[] = "DEMO.VOI";
  31.  
  32. /* sample rate of the data file */
  33.  
  34. unsigned int samples_per_sec = 16572;  // default for DVPT
  35.  
  36. /* compression algorithm to be used; 0 = none, 1 = uLaw, 2 = ADPCM */
  37.  
  38. int compression = 0;
  39.  
  40. /* name of the file where calibration information is to be stored */
  41.  
  42. char calfilename[] = "CALIB.FSS";
  43.  
  44. /*-------------------------------------------------------------------*/
  45.  
  46. void main(int argc, char **argv)
  47.  
  48. {
  49. int destination, returncode;
  50. char arg1[6], arg2[64];
  51.  
  52. /* get the destination parameter from the command line */
  53.  
  54. if ( argc < 2 )         // no parameters...
  55.     destination = -1;   // ... auto-locate
  56. else
  57.     {
  58.     argv++;                             // point to 1st parameter
  59.     if ( !stricmp(*argv, "LPT1") )
  60.         destination = 1;
  61.     else if ( !stricmp(*argv, "LPT2") )
  62.         destination = 2;
  63.     else if ( !stricmp(*argv, "LPT3") )
  64.         destination = 3;
  65.     else if ( !stricmp(*argv, "SPKR") )
  66.         destination = 0;               // use internal speaker
  67.     else
  68.         destination = -1;              // invoke auto-locate if parameter
  69.                                        //   is not interpretable
  70.     }
  71.  
  72. /* Step 1 (required only when destination changes): Save calibration info */
  73.  
  74.   /* create command line argument 1 */
  75.  
  76. if ( destination != -1 )
  77.     sprintf(arg1, "/S%1.1d%1.1d", destination, compression);
  78. else
  79.     sprintf(arg1, "/SA%1.1d", destination, compression);
  80.  
  81.   /* create command line argument 2 */
  82.  
  83. sprintf(arg2, "%u", samples_per_sec);
  84.  
  85.   /* invoke the executable */
  86.  
  87. returncode = _spawnl(_P_WAIT, "FSSPEAK.EXE", "FSSPEAK.EXE",
  88.                      arg1, arg2, calfilename, NULL);
  89.  
  90.   /* test return code; see docs for complete explanation */
  91.  
  92. if ( returncode != 1 )         // if not OK
  93.     {
  94.     printf("Calibration pass returned %d.\n", returncode);
  95.     exit(1);
  96.     }
  97.  
  98. /* Step 2: Play the data through the internal speaker or LPT port.
  99.            This can be done multiple times after a single calibration. */
  100.  
  101. _spawnl(_P_WAIT, "FSSPEAK.EXE", "FSSPEAK.EXE",
  102.         "/P", calfilename, datafilename, NULL);
  103.  
  104. }
  105.